﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace ES.Shared.Data
{
    [Serializable]
    public class TableInfo
    {
        public string TableName
        {
            get;
            set;
        }

        public TableSchemaType SchemaType
        {
            get;
            set;
        }

        public TableInfo()
        {
            _columns = new ColumnInfoCollection();
            _indexes = new KeyInfoCollection();
            _relations = new RelationInfoCollection();
        }

        public TableInfo(string tableName, TableSchemaType schemaType, ColumnInfo[] columns, KeyInfo[] indexes)
            : this()
        {
            TableName = tableName;
            SchemaType = schemaType;
            _columns.AddRange(columns);
            _indexes.AddRange(indexes);            
        }

        public TableInfo(string tableName, TableSchemaType schemaType, ColumnInfo[] columns, KeyInfo[] indexes, RelationInfo[] relations) : this()
        {
            TableName = tableName;
            SchemaType = schemaType;
            _columns.AddRange(columns);
            _indexes.AddRange(indexes);
            _relations.AddRange(relations);
        }

        private ColumnInfoCollection _columns;

        public ColumnInfoCollection Columns
        {
            get { return _columns; }
        }

        private KeyInfoCollection _indexes;

        public KeyInfoCollection Indexes
        {
            get { return _indexes; }
        }

        private RelationInfoCollection _relations;

        public RelationInfoCollection Relations
        {
            get { return _relations; }
        }
    }
}
